#pragma once
#include <vector>
#include <string>
#include "VectorXYZ.h"

class XY_Coordinate {
public:
	XY_Coordinate(float _x, float _y, float _u, float _v);
	~XY_Coordinate();
	float x,y;
	float u,v;
};

class Animation {
public:
	Animation(void);
	~Animation(void);
	
	void NextFrame();
	void SetLooping(bool loop);
	void SetAnimationSpeedMS(int milliseconds);
	void SetAnimationSpeed(int seconds);

	// each animation has a list of x,y coordinates that can be cycled through
	std::vector<XY_Coordinate*> coordinates;
	bool does_loop;
	int current_frame;
	int frame_delay;
};

struct Texture2DInfo {
	unsigned int texture_ID;
	int width, height;
};

struct Texture2DSize {
	int width, height;
	float normalized_width,normalized_height;
};

class Texture2D {
public:
	/* Constructor / Deconstructor */
	Texture2D(void);
	Texture2D(	std::string texture_file_name, 
				int num_of_animations =0, int current_anim =0,
				int frame_size_x =0, int frame_size_y =0);
	~Texture2D(void);

	/* Load / Initialize Functions */
	void LoadTexture(const char *file_name);
	void SetFrameSize(int width, int height);
	void SetNumberOfAnimations(int number);
	void AddAnimationFrame(int animation_number, int x, int y);
	void AddAnimationRow(	int animation_number, 
							int start_X, int start_Y, 
							int spacing_X, int spacing_Y, 
							int num_frames);

	/* Convenience Functions */
	void SetAllAnimationSpeeds(int seconds);
	void SetAllAnimationSpeedsMS(int milliseconds);
	void SetCurrentAnimation(int anim);
	void NextFrame();

	/* Draw Functions */
	void Draw();
	void Draw(VectorXYZ position, VectorXYZ orientation, VectorXYZ up, float scale =1, float width =0, float height =0);
	
	/* Data */
	Texture2DInfo sheet;
	Texture2DSize size;
	int number_of_animations;
	int current_animation;
	std::vector<Animation*> animations; // List of animations
};
